#include <stdio.h>
/*
* I_1.c
*
*  Created on: April, 23, 2009
*      Author: yimingliu@fudan.edu.cn
*/
#define N 16
typedef struct
{
	char num[10];
	int s;
} STREC;

int funI_3_fun(STREC *a, STREC *b,int l, int h)
{
	int i,j=0;
	for(i=0;i<N;i++)
		if(a[i].s>=l&&a[i].s<=h)
			b[j++]=a[i];
	return j;
}

void funI_3()
{
	STREC s[N]={{"GA05",85},{"GA03",76},{"GA02",69},
	            {"GA04",85},{"GA01",91},{"GA07",72},
	            {"GA08",64},{"GA06",87},{"GA015",85},
	            {"GA013",91},{"GA012",64},{"GA014",91},
	            {"GA011",91},{"GA017",64},{"GA018",64},
	            {"GA016",72}};
	STREC h[N],tt;
	int i,j,n,low,heigh,t;
	FILE *out;
	printf("Enter 2 integer number low & height: ");
	scanf("%d%d",&low,&heigh);
	if(heigh<low)
	{
		t=heigh;
		heigh=low;
		low=t;
	}
	n=funI_3_fun(s,h,low,heigh);
	printf("The student's data between %d--%d: \n",low,heigh);
	for(i=0;i<n;i++)
		printf("%s %4d\n",h[i].num,h[i].s);
	printf("\n");
	out=fopen("out18.data","w");
	n=funI_3_fun(s,h,80,98);
	fprintf(out,"%d\n",n);
	for(i=0;i<n-1;i++)
		for(j=i+1;j<n;j++)
			if(h[i].s>h[j].s)
			{
				tt=h[i];
				h[i]=h[j];
				h[j]=tt;
			}
	for(i=0;i<n;i++)
		fprintf(out,"%4d\n",h[i].s);
	fprintf(out,"\n");
	fclose(out);
}